package com.music.service.songs.service;

import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Required;

import com.music.service.playlists.beans.Playlist;
import com.music.service.songs.beans.Song;
import com.music.service.songs.dao.SongDAO;

public class SongServiceImpl implements SongService {
	private SongDAO mSongDAO;

	/**
	 * @return the songDAO
	 */
	public SongDAO getSongDAO() {
		return mSongDAO;
	}

	/**
	 * @param pSongDAO the songDAO to set
	 */
	@Required
	public void setSongDAO(SongDAO pSongDAO) {
		mSongDAO = pSongDAO;
	}

	
	public Song addNewSong(Long pMemberId,Song pSong){
		pSong.setCreatedMemberId(pMemberId);
		return getSongDAO().addNewSong(pSong);
	}

	public Song addNewSong(Long pMemberId,String pSongName){
		Song song = new Song();
		
		song.setCreatedMemberId(pMemberId);
		song.setName(pSongName);
		
		return getSongDAO().addNewSong(song);
	}
	
	public boolean checkMemberPermissionForSong(Long pMemberId, Long pSongId) {
		return getSongDAO().checkMemberPermissionForSong(pMemberId, pSongId);
	}

	
	public void deleteSong(Song pSong){
		 getSongDAO().deleteSong(pSong);
	}

	
	public Song editSong(Song pSong) {
		return getSongDAO().editSong(pSong);
	}

	
	public boolean setPreferredUrlForSongForMember(Long pMemberId,
			Long pSongId, Long pUrlId) {
		return getSongDAO().setPreferredUrlForSongForMember(pMemberId, pSongId, pUrlId);
	}

	
	public List<Song> viewSongs(Collection<Long> pSongIds) {
		return getSongDAO().viewSongs(pSongIds);
	}

	
	public List<Song> getSongsFromPlaylist(Playlist pPlaylist) {
		
		return getSongDAO().viewSongs(pPlaylist.getSongIds());
	}

	public List<Long> getUrlsForSongsForMember(Long pMemberId,
			Set<Long> pSongIds) {
		return getSongDAO().getUrlsForSongsForMember(pMemberId, pSongIds);
	}
	
	
}
